package com.kkb.shopcenter.server.impl;

import com.kkb.shopcenter.api.PageService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;

import java.io.FileWriter;
import java.io.IOException;

@Service
public class PageServiceImpl implements PageService {


    @Autowired
    private TemplateEngine templateEngine;

    @Override
    public String staticBuild() {
        FileWriter fileWriter = null;
        String result = null;
        try {
             fileWriter = new FileWriter("/Users/hadoop/Desktop/hello.html");

            Context context = new Context();
            context.setVariable("hello","hello every one ");
            templateEngine.process("hello",context,fileWriter);
            result = "ok";
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }
}
